//
//  FBDConversationListViewController.m
//  baodongPro
//
//  Created by feng on 16/8/18.
//  Copyright © 2016年 proper. All rights reserved.
//

#import "FBDConversationListViewController.h"
#import "FBDChatListViewController.h"
#import "NavBarTools.h"
#import "FBDAddFriendsViewController.h"
@interface FBDConversationListViewController ()<EaseConversationListViewControllerDelegate>
@property(nonatomic,strong)NavBarTools* tool;

@end
@implementation FBDConversationListViewController
{


    
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self refresh];
    [self refreshDataSource];
    [[APPDelegate_FBD fbd_tabBarVC] setupUnreadMessageCount];
    

}
/**
 *      @author 冯宝东
 *
 *      懒加载初始化
 *
 *      @return 导航工具类
 */
-(NavBarTools*)tool
{
    if (!_tool) {
        _tool=[NavBarTools defaultTools];
    }
    return _tool;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
     self.delegate=self;
    [self.tool settingNavBarColorWithCurrentController:self];
    [self.tool settingNavBarTitle:@"消息列表MM" rightItems:@[@"消息1",@"消息2"] currentVC:self rightItemBarAction:^(UIBarButtonItem *rightBarbutton) {
        FBDAddFriendsViewController* addFriendsVC=[[FBDAddFriendsViewController alloc] init];
        addFriendsVC.hidesBottomBarWhenPushed=YES;
        [self.navigationController pushViewController:addFriendsVC animated:YES];
        
        
        
        
        
        
    }];
    
    
}

#pragma mark - public

-(void)refresh
{
    [self refreshAndSortView];
}
-(void)refreshDataSource
{
    [self tableViewDidTriggerHeaderRefresh];
}

/*!
 @method
 @brief 获取点击会话列表的回调
 @discussion 获取点击会话列表的回调后,点击会话列表用户可以根据conversationModel自定义处理逻辑
 @param conversationListViewController 当前会话列表视图
 @param IConversationModel 会话模型
 */
- (void)conversationListViewController:(EaseConversationListViewController *)conversationListViewController
            didSelectConversationModel:(id<IConversationModel>)conversationModel
{
    
    EaseConversationModel *model = conversationModel;
    FBDChatListViewController *viewController = [[FBDChatListViewController alloc] initWithConversationChatter:model.conversation.conversationId conversationType:model.conversation.type];
    viewController.title = model.title;
    viewController.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:viewController animated:YES];
    [[APPDelegate_FBD fbd_tabBarVC] setupUnreadMessageCount];

}
-(void)rightBarButtonItemPressed:(UIBarButtonItem*)barItem
{


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
